import React, { useEffect, useState } from 'react'
import http from '../../utils/http'
import {useParams } from 'react-router-dom'
import { ProductCard } from 'react-vant';
import NavBars from '../../components/NavBars';

function Index() {
  
  const { id } = useParams()
  const [detail, setDetail] = useState({})
  const getDetail = async () => {
    const res = await http.get('/api/list/detail', { params: { id } })

    console.log(res);

    const { data, code } = res.data

    if (code === 200) {
      setDetail(data)
    }


  }

  useEffect(() => {
    getDetail()
  },[])
  return (
    <div>
      <NavBars title='详情页'></NavBars>
      <div>
        <ProductCard
          num={detail.date}
          price={detail.price}
          desc={detail.title}
          title={detail.id}
          thumb={detail.image}
        />
      </div>
    </div>
  )
}

export default Index
